package com.dl.blog.controller;

import com.alibaba.fastjson.JSONObject;
import com.dl.blog.service.impl.ApiServiceImpl;
import com.dl.dlcommon.utils.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DL
 * @create 2025-07-07 下午9:45
 */
@RestController
@RequestMapping("/api/")
public class ApiController {

    @Autowired
    private ApiServiceImpl apiService;

    /**
     * 记录页面访问
     */
    @GetMapping("/local")
    public Result<?> recordVisit() {
        JSONObject locationByIp = apiService.getLocationByIp();
        return Result.success(String.valueOf(locationByIp));
    }
}
